import 'package:myapp/util/sp_cache.dart';

class AppCache {

  AppCache._();

  static AppCache _instance = AppCache._();

  ///预初始化，防止在使用get时，prefs还未完成初始化
  static AppCache get() {
    return _instance;
  }

  static const String _ACCOUNT = "ACCOUNT";
  static const String _TOKEN = "TOKEN";

  void saveTokenAndRole(String token,String account) {
    SpCache.getInstance().setString(_ACCOUNT, account);
    SpCache.getInstance().setString(_TOKEN, token);
  }



  String getAccount(){
    String? s=SpCache.getInstance().get(_ACCOUNT);
    return s??"";
  }

  String getToken(){
    String? s=SpCache.getInstance().get(_TOKEN);
    return s??"";
  }
}
